<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>Three_TDT</title>
    <script src="/Public/js/tianditu.api.js"></script>
    <script src="/Public/js/jquery-3.7.1.min.js"></script>
    <link rel="icon" href="/Public/imgs/H.ico">
    <style>
        html,
        body {
            margin: 0;
            padding: 0;
            width: 100%;
            height: 100%;
            overflow: hidden;
        }

        #map {
            position: relative;
            width: 100%;
            height: 100%;
            cursor: default;
        }

        #getDem {
            position: absolute;
            bottom: 100px;
            left: 20px;
            z-index: 450;
            width: 50px;
            height: 200x;
        }
    </style>
</head>

<body>
    <div id="map"></div>
    <button id="getDem">T</button>



    <script>
        var map = new T.Map('map', { tileSize: 512 });
        map.centerAndZoom(new T.LngLat(103, 30), 14);
        var ctrl = new T.Control.MapType(
            { position: T_ANCHOR_BOTTOM_RIGHT }
        );
        map.addControl(ctrl);
        var recTool = new T.RectangleTool(map, { showLabel: false });;

        async function HD1() {
            $('#threeCon1').css('visibility', 'hidden')
            recTool.removeEventListener('draw');
            recTool.clear();
            recTool.open();
            const bbox = await getBbox()
            // await t(bbox)
            console.log(bbox)
        }

        $('#getDem').on('click', HD1)

        function getBbox() {
            return new Promise((resolve, reject) => {
                const handler = (e) => {
                    const bbox = e.currentBounds;
                    recTool.removeEventListener('draw', handler);
                    resolve(bbox);
                };
                recTool.addEventListener('draw', handler);
            });
        }


    </script>
</body>

</html>